﻿package {
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	/**
	 * ...
	 * @author kot
	 * мяу
	 */
	public class Rook extends Figure {
		
		private var moved : Boolean = false;
		
		public function isMoved() : Boolean {
			return this.moved;
		}
		public function setMoved() : void {
			this.moved = true;
		}
		
		override public function toString():String {
			return "Rook";
		}
		
		override public function getAvailableMoves(): int {
			resetMoves();
			waveMove(1, 0);
			waveMove(0, 1);
			waveMove(-1, 0);
			waveMove(0, -1);
			return moves.length;
		}
		
		override public function canMove(x : int, y : int) : Boolean {
			if (figureX == x && figureY == y)
				return true;
			resetMoves();
			waveMove(1, 0);
			waveMove(0, 1);
			waveMove(-1, 0);
			waveMove(0, -1);
			for (var i = 0; i < moves.length; i++) {
				var t : Point = moves[i];
				if (t.x == x && t.y == y) {
					return true;
				}
			}
			return false;
		}
	}
	
}